package com.jiulong.springboot_validator.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RabbitmqConfig {
    //声明交换机
    @Bean("test_exchange")
    public Exchange EXCHANGE_TOPICS_INFORM(){
        //durable(true)持久化，mq重启之后交换机还在
        return ExchangeBuilder.topicExchange("test_exchange").durable(true).build();
    }

    //声明队列
    @Bean("test_queue")
    public Queue QUEUE_TOPICS_INFORM(){
        //durable(true)持久化，mq重启之后交换机还在
        return new Queue("test_queue");
    }

    //声明队列
    @Bean
    public Binding BINDING_QUEUE_TOPICS_INFORM(@Qualifier("test_queue")Queue queue,@Qualifier("test_exchange")Exchange exchange){
        //durable(true)持久化，mq重启之后交换机还在
        return BindingBuilder.bind(queue).to(exchange).with("").noargs();
    }
}
